
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>功能API</title>
    <link href="/static/devtools30/layui-v2.5.6/css/layui.css" rel="stylesheet" />
    <link href="/static/devtools30/layui-v2.5.6/ext/soulTable/soulTable.css" rel="stylesheet"/>
    <link href="/static/devtools30/css/devindexbase.css" rel="stylesheet" />
    <script src="/static/devtools30/js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="/static/devtools30/layui-v2.5.6/layui.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/devtoolCommon.js" type="text/javascript"></script>

    <link href="/static/devtools30/js/plugins/codemirror-5.14.2/theme/eclipse.css" rel="stylesheet" type="text/css" />
    <link href="/static/devtools30/js/plugins/codemirror-5.14.2/lib/codemirror.css" rel="stylesheet" />
    <link href="/static/devtools30/js/plugins/codemirror-5.14.2/addon/display/fullscreen.css" rel="stylesheet" />
    <script src="/static/devtools30/js/plugins/codemirror-5.14.2/lib/codemirror.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/plugins/codemirror-5.14.2/mode/sql/sql.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/plugins/codemirror-5.14.2/addon/display/fullscreen.js" type="text/javascript"></script>


</head>
<style>
    /*-------------------------tab-------------------------*/

    .layui-tab {
        margin: 0;
    }


    /*边框*/

    .layui-tab-title {
        border-bottom-width: 3px;
        border-bottom-color: #f7f7f7;
    }


    /*字体*/

    .layui-tab-title li {
        font-size: 11px!important;
    }


    /*高度*/

    .tabwrap .layui-tab-title {
        height: 24px;
    }


    /*高度*/

    .tabwrap .layui-tab-title li {
        line-height: 24px;
    }


    /*高度*/

    .tabwrap .layui-tab-title .layui-this:after {
        height: 24px;
    }

    .layui-tab-title .layui-this:after {
        /*height: auto!important;*/
    }


    /*选中时样式*/

    .tabwrap .layui-tab-title .layui-this {
        color: white;
        background: #41BFC0;
    }


    /*关闭按钮样式*/

    .tabwrap .layui-tab-title li .layui-tab-close {
        color: #FFFFFF!important;
    }





    /*表格字体大小*/

    .layui-table td,
    .layui-table th {
        font-size: 11px!important;
    }


    /*表格边距*/

    .layui-table,
    .layui-table-view {
        margin: 0;
    }



    .layui-btn-primary2 {
        border: 0px solid #C9C9C9;
        /*color: #0066CC;*/
        /*background-color: transparent;*/
        background: #41BFC0;
    }
    .layui-btn {
        height: 26px;
        line-height: 26px;
        font-size: 11px;
        margin-bottom: 2px;
    }
    .textheight {
        height: 220px;
    }

    .sqlheght {
        height: 300px;
    }
    .CodeMirror {
        border: 1px solid #eee;
    }
    .jsonwrap{
        height: 300px;
    }
    .layui-input-block{
        margin-left: 0!important;
    }
    .addwrap {
        padding-top: 40px;
    }

    .addwrap .layui-input,
    .layui-select {
        height: 25px;
    }

    .addwrap .layui-input-block {
        min-height: 26px;
        margin-left: 70px;
    }

    .addwrap .layui-form-label {
        padding: 0;
        text-align: left;
        height: 26px;
        line-height: 26px;
        width: 70px;
    }

    .layui-form-mid {
        line-height: normal!important;
    }

    .layui-form-item .layui-input-inline {
        width: 250px;
    }
    .form-design-btn {
        position: absolute;
        right: 10px;
         top: 2px;

        z-index: 99999;

    }
    .open_link{
        display: inline-block;
        text-align: center;
        width: 68px;
        height: 26px;
        line-height: 26px;
        /*padding: 0px 10px;*/

        background-color: #1E9FFF;
        color: #fff!important;

         /*font-weight: 800;*/
    }
    .link_open_sec{
        margin-left: -3px;
        background-color: #fff;
        color: #555 !important;
        border: 1px solid #C9C9C9;
        height: 24px !important;
        line-height: 24px !important;
    }
</style>
<body>

<div>

    <div class="layui-tab tabwrap " lay-filter="tab" style="margin-top: 5px">
        <ul class="layui-tab-title" >
            <li onclick="showEditor()" class="layui-this">导入配置</li>
<!--            <li>SQL校验</li>-->
        </ul>
        <div class="layui-tab-content">



            <div class="layui-tab-item layui-show">
                <div class="flex flex-align-center flex-jusity-betreen tophead backgroundf" style="border-bottom: 2px solid #F7F7F7;">
                    <div class="colorred">列名为导入Excel的列名</div>
                    <div class="layui-btn-group btns tab3 ">


                        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" name='tab3_tab04'>新增</button>

                    </div>
                </div>
                <div class="backgroundf">
                    <table id="mygrid" lay-filter="mygrid"></table>
                </div>
            </div>

            <div class="layui-tab-item">
                <div class="flex flex-align-center flex-jusity-end tophead backgroundf" style="padding: 0;">
                    <div class="layui-btn-group btns tab6">
                        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="editOtherBtn()"  >新增</button>

                    </div>
                </div>
                <div class="backgroundf">
                    <table id="mygrid4" lay-filter="mygrid4"></table>
                </div>
            </div>

            <div class="layui-tab-item">
                <div class="flex flex-align-center flex-jusity-end tophead backgroundf" style="padding: 0;">
                    <div class="layui-btn-group btns tab6">
                        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="editSqlEdit('','0')"  >新增SQL校验</button>
                        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="editSqlEdit('','1')"  >新增JS校验</button>

                    </div>
                </div>
                <div class="backgroundf">
                    <table id="mygrid7" lay-filter="mygrid7"></table>
                </div>
            </div>
        </div>
    </div>
</div>


</body>
<script>
    var height = dlCommon.getWinHeight();
    var width=dlCommon.getWinWidth();
    var editor=null;
    var dataid=dlCommon.getUrlParam("id");


    layui.config({
        base: '/static/devtools30/layui-v2.5.6/ext/',// 第三方模块所在目录
        version: 'v1.5.10' // 插件版本号
    }).extend({
        soulTable: 'soulTable/soulTable',
        tableChild: 'soulTable/tableChild',
        tableMerge: 'soulTable/tableMerge',
        tableFilter: 'soulTable/tableFilter',
        excel: 'soulTable/excel',
        treeGrid: 'treegrid/treeGrid',
        xmSelect: 'xmSelect/xm-select',
        multiSelect: 'multiSelect/multiSelect'
    });

    layui.use(['form', 'table', 'soulTable', 'laypage', 'layer', 'xmSelect', 'util', 'laydate', 'multiSelect'], function () {

        loadTab();

        initGrid();//初始表单

        initEvent();//初始化事件


        getHeadList();//表头列表

        getSqlCheckData()//sql校验数据

        layui.form.render();
    });

    function loadTab() {
        var devtExcelEntity = unescape('[(${devtExcelEntity})]')==''?"":JSON.parse(unescape('[(${devtExcelEntity})]'));
        $("#importConfig").show();
    }





    function editHead(id){
        var url="/DevtExcelFieldController/toEdit?excelId="+dataid;
        if(id){
            url+="&id="+id;
        }
        dlCommon.layeropen(600,400,"编辑",url)
    }



    function delHead(id){
        if(!id){
            dlCommon.layerInfo("请选择要删除的数据")
            return;
        }
        dlCommon.layerConfirm("确定要删除该数据吗？",function(){
            dlCommon.getJSON("/DevtExcelFieldController/delete",{id:id},function(res){
                if(!res.success){
                    dlCommon.layerError(res.msg);
                    return;
                }

                getHeadList();


            },true);
        })

    }



    function getHeadList(){
        layui.table.reload("mygrid",{
            url:"/DevtExcelFieldController/getFieldList",
            loading:true,
            where:{excelId:dataid}

        });
    }





    function getOtherBtnList(){
        layui.table.reload("mygrid4",{
            url:"/DevtFormListTemplOtherBtn/getAll",
            loading:true,
            where:{pid:dataid}

        });
    }

    function editOtherBtn(id){
        var url="/DevtFormListTemplOtherBtn/toEdit?pid="+dataid;
        if(id){
            url+="&id="+id;
        }
        dlCommon.layeropen(800,410,'按钮配置',url);
    }

    function delOtherBtn(id){
        if(!id){
            dlCommon.layerInfo("请选择要删除的数据")
            return;
        }
        dlCommon.layerConfirm("确定要删除该数据吗？",function(){
            dlCommon.getJSON("/DevtFormListTemplOtherBtn/delete",{id:id},function(res){
                if(!res.success){
                    dlCommon.layerError(res.msg);
                    return;
                }
                dlCommon.layerSuccess("删除成功",function(){
                    getOtherBtnList();
                })

            },true);
        })
    }

    function getSqlCheckData() {
        layui.table.reload("mygrid7",{
            url:"/DevtFormListTemplateSqlCheckController/getAllByPid",
            loading:true,
            where:{pid:dataid}

        });
    }


    function editSqlEdit(id,type){
        var url="/DevtExcelFieldController/toEdit?excelId="+type+"&tempid="+dataid;
        if(id){
            url+="&id="+id;
        }
        dlCommon.layeropen(width*0.8,height*0.93,'新增Sql校驗',url);
    }

    function initGrid(){

        layui.table.render({
            elem: '#mygrid',
            height: height-100,
            //width: 244,
            size: 'sm' //小尺寸的表格
            ,

            page: false //开启分页
            ,
            cols: [
                [ //表头
                    {field: 'xh', title: '序号', width: '10%'},
                    { field: 'name', title: '表头名称', width: '20%' },
                    { field: 'fieldName', title: '模型字段名称', width: '10%', },
                    { field: 'fieldCode', title: '模型字段代码', width: '10%', },
                    { field: 'opera', title: '操作', width: '20%' , templet: function(d){
                            var str="";
                            str += '<button type="button" onclick="editHead(\''+d.id+'\')" class="layui-btn layui-btn-normal layui-btn-xs layui_edit_btn">修改</button>';
                            str += '<button type="button" onclick="delHead(\''+d.id+'\')" class="layui-btn layui-btn-danger layui-btn-xs layui_edit_btn">删除</button>';

                            return str;
                        }},
                ]
            ]
        });
        layui.table.render({
            elem: '#mygrid2',
            height: height-100,
            //height: 581,
            //width: 600,
            size: 'sm' //小尺寸的表格
            ,
            page: false //开启分页
            ,
            cols: [
                [ //表头
                    //{field: 'id', title: '分类', width:80, fixed: 'left'}
                    {field: 'xh', title: '序号', width: '5%',type:"numbers"},
                    { field: 'arglable', title: '显示名称', width: '15%' },
                    { field: 'argname', title: '唯一代码', width: '15%' },
                    { field: 'lxLable', title: '类型', width: '10%', },
                    { field: 'isshow', title: '显示', width: '10%',templet:'<span>{{isYes(d.isshow) }}</span>' },
                    { field: 'jlsrccode', title: '关联控件', width: '10%' },
                    { field: 'bz', title: '备注' },
                    {field: 'opera', title: '操作', width: '10%', templet: function(d){
                            var str="";
                            str += '<button type="button" onclick="editSearchArg(\''+d.id+'\')" class="layui-btn layui-btn-normal layui-btn-xs layui_edit_btn">修改</button>';
                            str += '<button type="button" onclick="delSearchArg(\''+d.id+'\')" class="layui-btn layui-btn-danger layui-btn-xs layui_edit_btn">删除</button>';

                            return str;
                        }},
                ]
            ]
        });

        layui.table.render({
            elem: '#mygrid4',
            height: height-100,
            size: 'sm',
            page: false,
            cols: [
                [ //表头
                    //{field: 'id', title: '分类', width:80, fixed: 'left'}
                    {field: 'xh', title: '序号', width: '5%',type:"numbers"},
                    { field: 'btnlabel', title: '显示名称', width: '15%' },
                    { field: 'positionshow', title: '显示位置', width: '10%', },
                    { field: 'actionshow', title: '动作类型', width: '15%' },
                    { field: 'useflagshow', title: '启用', width: '10%' },
                    { field: 'bz', title: '备注' },
                    {field: 'opera', title: '操作', width: '10%', templet: function(d){
                            var str="";
                            str += '<button type="button" onclick="editOtherBtn(\''+d.id+'\')" class="layui-btn layui-btn-normal layui-btn-xs layui_edit_btn">修改</button>';
                            str += '<button type="button" onclick="delOtherBtn(\''+d.id+'\')" class="layui-btn layui-btn-danger layui-btn-xs layui_edit_btn">删除</button>';

                            return str;
                        }},
                ]
            ]
        });

        layui.table.render({
            elem: '#mygrid7',
            height: height-100,
            //width: 244,
            size: 'sm', //小尺寸的表格
            page: false, //开启分页
            cols: [
                [ //表头
                    //{field: 'id', title: '分类', width:80, fixed: 'left'}
                    {field: 'xh', title: '序号', width: '5%',type:"numbers"},
                    { field: 'name', title: '校验名称', width: '10%' },
                    { field: 'checktype', title: '校验类型', width: '10%', },
                    { field: 'active', title: '激活', width: '10%', },
                    { field: 'errorinfo', title: '错误消息提示',  },
                    { field: 'fieldcode', title: '字段' },

                    { field: 'bz', title: '备注', },
                    {field: 'opera', title: '操作', width: '10%', templet: function(d){
                        var str="";
                        var type=0
                        if(d.checktype=="customjs"){
                            type=1;
                        }

                        str += '<button type="button" onclick="editSqlEdit(\''+d.id+'\',\''+type+'\')" class="layui-btn layui-btn-normal layui-btn-xs layui_edit_btn">修改</button>';
                        str += '<button type="button" onclick="delTjOptCheck(\''+d.id+'\',\'\')" class="layui-btn layui-btn-danger layui-btn-xs layui_edit_btn">删除</button>';

                        return str;
                    }},
                ]
            ]
        });
    }

    function delTjOptCheck(id){
        if(!id){
            dlCommon.layerInfo("请选择要删除的数据")
            return;
        }
        dlCommon.layerConfirm("确定要删除该数据吗？",function(){
            dlCommon.getJSON("/DevtFormListTemplateSqlCheckController/delete",{id:id},function(res){
                if(!res.success){
                    dlCommon.layerError(res.msg);
                    return;
                }
                dlCommon.layerSuccess("删除成功",function(){
                    getSqlCheckData();
                })

            },true);
        })

    }

    function isYes(val) {
        if (val) {
            return "是";
        } else {
            return "否";
        }
    }

    function showEditor(){
        setTimeout(function (){
            // var evt = document.createEvent("MouseEvents");
            // evt.initEvent("mousedown", false, true, window, 1, 84, 416, 75, 260, false, false, false, false, 0, null);
            // $("div.codemirror-scroll")[0].dispatchEvent(evt);
        },500);
    }

    function initEvent(){



        //对应表，导入json，新增表，新增一行 按钮点击事件
        $('.tab3>button').on('click', function() {
            var names = $(this)[0].name;

            if(names == 'tab3_tab04') {
                editHead();

            }
        })
        //sql窗口，历史版本 按钮点击事件
        $('.tab4>button').on('click', function() {
            var names = $(this)[0].name;

            if(names == 'tab4_tab01') {
                dlCommon.layerMsg("按ESC退出全屏")
                // editor.setOption("fullScreen", true);
                // editor.focus();

            }

        })

        //增加JSON校验，增加JS校验 按钮点击事件
        $('.tab6>button').on('click', function() {
            var names = $(this)[0].name;
            if(names == 'tab6_tab01') {
                editSearchArg();

            }

        })


        layui.form.render();

    }

</script>

</html>